//
//  DataBase.m
//  婚礼记考核
//
//  Created by dllo on 15/7/7.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "DataBase.h"

@implementation DataBase
-(void)dealloc
{
    [super dealloc];
}
#pragma mark - 初始化
- (instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        //KVC赋值
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}
//遍历构造器方法
+(instancetype)baseModelWithDic:(NSDictionary *)dic
{
    id objc = [[[[self class] alloc]initWithDic:dic] autorelease];
    return objc;
}

#pragma mark - 转化方法
//转化方法(数组套字典 -->数组套maodel)
+ (NSMutableArray *) arrayWithModelByArray:(NSArray *) array
{
    //创建一个可变数组  保存model  并返回结果
    NSMutableArray *arr = [NSMutableArray array];
    //遍历参数数组  跟autorelease配对
    for (NSDictionary *dic in array) {
        //自动释放池
        @autoreleasepool {
            //创建对象
            id model = [[self class] baseModelWithDic:dic];
            //添加数组
            [arr addObject:model];
            
        }
    }
    return arr;
}


#pragma mark- KVC容错方法

- (void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

- (id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}

@end
